import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:share_fit/app/components/back_btn_icon.dart';
import 'package:share_fit/app/helper/ext/tr_ext.dart';
import 'package:share_fit/app/tools/color_const.dart';
import 'package:share_fit/generated/locales.g.dart';

import 'weight_setting_logic.dart';

class WeightSettingPage extends StatelessWidget {
  WeightSettingPage({super.key});

  final logic = Get.put(WeightSettingLogic());
  final state = Get.find<WeightSettingLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(LocaleKeys.settings_weight.ts),
        centerTitle: true,
        leading: BackBtnIcon(onTap: () => Get.back()),
      ),
      body: Padding(
        padding: EdgeInsets.only(left: 40.w, top: 80.h, right: 40.w),
        child: ListView(
          children: [
            Container(
              height: 175.h,
              padding: EdgeInsets.only(left: 59.w, right: 36.w),
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(20),
              ),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(
                      LocaleKeys.settings_weight_enable.ts,
                      style: TextStyle(
                          fontSize: 42.sp, color: ColorConst.primaryFontColor),
                    ),
                    Transform.scale(
                        scale: 0.7,
                        child: Obx(() => Switch(
                            value: state.isWeightSyncEnable.value,
                            activeColor: ColorConst.mainBgColor,
                            activeTrackColor: ColorConst.accentColor,
                            onChanged: (value) {
                              logic.setWeightSyncEnable(value);
                            })))
                  ]),
            ),
            Container(
              padding: EdgeInsets.only(left: 102.w, top: 39.h),
              child: Text(LocaleKeys.settings_weight_tips.ts,
                  style: TextStyle(
                      fontSize: 42.sp, color: ColorConst.primaryFontColor)),
            ),
          ],
        ),
      ),
    );
  }
}
